<!DOCTYPE html>
<html>
<head>
<script src="../resources/testharness.js"></script>
<script src="../resources/testharnessreport.js"></script>
</head>
<body>
<script type="text/javascript">
if (window.testRunner) {
  // Inject a subresource filter to disallow 'beta.js' (but not 'alpha.js').
  testRunner.setDisallowedSubresourcePathSuffixes(["beta.js"], true /* block_subresources */);
}

document.scriptsExecuted = [];
document.notifyScriptExecuted = function(basename) {
  document.scriptsExecuted.push(basename);
}

async_test(t => {
  var s = document.createElement("script");
  s.onload = t.step_func_done(_ => {
    assert_in_array("alpha", document.scriptsExecuted, "Scripts that are not disallowed are still executed.");
  });
  s.onerror = t.unreached_func();
  s.src = "http://localhost:8000/resources/redirect.php?url=/subresource_filter/resources/alpha.js";
  document.body.appendChild(s);
}, "Resources for which no URLs in the redirect chain are disallowed are still loaded.");

async_test(t => {
  var s = document.createElement("script");
  s.onload = t.unreached_func();
  s.onerror = t.step_func_done();
  s.src = "http://localhost:8000/resources/redirect.php?url=/subresource_filter/resources/beta.js";
  document.body.appendChild(s);
}, "Resources that redirect to a disallowed URL are not loaded.");

</script>
</body>
</html>
